use rbatis::{
    crud, impl_delete, impl_select, impl_select_page, impl_update, rbdc::datetime::FastDateTime,
};

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AdobeCompensateLog {
    id: Option<u64>,
    payload_hash: Option<String>,
    response_value: Option<String>,
    create_time: Option<FastDateTime>,
    job_name: Option<String>,
    date_from: Option<String>,
    date_to: Option<String>,
}

crud!(AdobeCompensateLog {});

impl_select!(AdobeCompensateLog{select_all_by_id(id:&str,job_name:&str) => "`where id = #{id} and job_name = #{name}`"});
impl_select!(AdobeCompensateLog{select_by_name(job_name:&str) -> Option => "`where job_name = #{job_name} limit 10`"});
impl_select!(AdobeCompensateLog{select_by_id(id:&str) -> Option => "`where id = #{id} limit 1`"});
impl_update!(AdobeCompensateLog{update_by_name(name:&str) => "`where id = '2'`"});
impl_delete!(AdobeCompensateLog {delete_by_name(job_name:&str) => "`where job_name= '2'`"});
impl_select_page!(AdobeCompensateLog{select_page() =>"
  
     if !sql.contains('count'):
       `order by create_time desc`"});
impl_select!(AdobeCompensateLog{select_page_by_name(name:&str) =>"
     if name != null && name != '':
       `where name != #{name}`
     if name == '':
       `where name != ''`"});
